package com.ticket.sass.admin.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.ticket.sass.common.entity.tenant.OrderEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author ywb
 * @since 2024-03-07
 */
public interface OrderMapper extends BaseMapper<OrderEntity> {

    @Select("""
        SELECT  
            SUM(pay_price) AS sum_pay_price,  
            SUM(CASE WHEN pay_type = 1 THEN pay_price ELSE 0 END) AS wx_sum_pay_price,
            SUM(CASE WHEN pay_type = 3 THEN pay_price ELSE 0 END) AS member_sum_pay_price,
            COUNT(*) AS total_records
        FROM  
            orders
         ${ew.customSqlSegment}
        """)
    OrderEntity  dateCount(@Param(Constants.WRAPPER) QueryWrapper<OrderEntity> queryWrapper);
    
}
